package com.lekang.le.service.impl;

import java.util.List;
import com.lekang.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lekang.le.mapper.RoomTypeMapper;
import com.lekang.le.domain.RoomType;
import com.lekang.le.service.IRoomTypeService;

/**
 * 房型设置Service业务层处理
 * 
 * @author szh
 * @date 2025-10-14
 */
@Service
public class RoomTypeServiceImpl implements IRoomTypeService 
{

    @Autowired
    private RoomTypeMapper roomTypeMapper;

    @Override
    public int enableRoomType(Long id) {
        RoomType roomType = new RoomType();
        roomType.setId(id);
        roomType.setStatus(1L); // 假设1代表“启用”，需与字典配置一致
        return roomTypeMapper.updateRoomTypeStatus(roomType);
    }

    @Override
    public int disableRoomType(Long id) {
        RoomType roomType = new RoomType();
        roomType.setId(id);
        roomType.setStatus(0L); // 假设0代表“禁用”，需与字典配置一致
        return roomTypeMapper.updateRoomTypeStatus(roomType);
    }

    /**
     * 查询房型设置
     * 
     * @param id 房型设置主键
     * @return 房型设置
     */
    @Override
    public RoomType selectRoomTypeById(Long id)
    {
        return roomTypeMapper.selectRoomTypeById(id);
    }

    /**
     * 查询房型设置列表
     * 
     * @param roomType 房型设置
     * @return 房型设置
     */
    @Override
    public List<RoomType> selectRoomTypeList(RoomType roomType)
    {
        return roomTypeMapper.selectRoomTypeList(roomType);
    }

    /**
     * 新增房型设置
     * 
     * @param roomType 房型设置
     * @return 结果
     */
    @Override
    public int insertRoomType(RoomType roomType)
    {
        roomType.setCreateTime(DateUtils.getNowDate());
        return roomTypeMapper.insertRoomType(roomType);
    }

    /**
     * 修改房型设置
     * 
     * @param roomType 房型设置
     * @return 结果
     */
    @Override
    public int updateRoomType(RoomType roomType)
    {
        return roomTypeMapper.updateRoomType(roomType);
    }

    /**
     * 批量删除房型设置
     * 
     * @param ids 需要删除的房型设置主键
     * @return 结果
     */
    @Override
    public int deleteRoomTypeByIds(Long[] ids)
    {
        return roomTypeMapper.deleteRoomTypeByIds(ids);
    }

    /**
     * 删除房型设置信息
     * 
     * @param id 房型设置主键
     * @return 结果
     */
    @Override
    public int deleteRoomTypeById(Long id)
    {
        return roomTypeMapper.deleteRoomTypeById(id);
    }

    /**
     * 查询热门房型列表（小程序端使用）
     * 查询启用状态且未删除的房型
     * 
     * @return 房型设置集合
     */
    @Override
    public List<RoomType> selectHotRoomTypeList()
    {
        return roomTypeMapper.selectHotRoomTypeList();
    }
}
